package cn.sunjinxin.trade.domain.enums;

import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.experimental.FieldDefaults;

import java.util.Arrays;
import java.util.Objects;

/**
 * @author issavior
 */
@AllArgsConstructor
@Getter
@FieldDefaults(makeFinal = true, level = lombok.AccessLevel.PRIVATE)
public enum FundType {

    FORWARD(1, "正向支付"),
    REVERSE(2, "逆向扣款"),

    UNKNOWN(-1, "其他");

    private final Integer code;
    private final String msg;

    public static FundType of(Integer code) {
        return Arrays.stream(FundType.values())
                .filter(e -> Objects.equals(e.getCode(), code))
                .findFirst()
                .orElse(null);
    }
}
